

package com.qiyu.mq.core.controller;

import com.qiyu.mq.core.annotation.MqProvider;
import com.qiyu.mq.core.producer.MqProducerTemplate;
import com.qiyu.mq.core.serializer.FastJsonSerializer;
import org.apache.rocketmq.client.producer.SendResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author idea
 * @version V1.0
 * @date 2020/8/10
 */
@RestController
@RequestMapping(value = "/test")
public class TestController {

    @MqProvider(topic = "Qiyu-Topic", serializer = FastJsonSerializer.class, tag = "test-tag")
    private MqProducerTemplate<String> mqProducerTemplate;

    @GetMapping(value = "/send")
    public String test() {
        SendResult sendResult = mqProducerTemplate.send("this is a test word for mq provider");
        System.out.println("发送结果为：" + sendResult);
        System.out.println("test");
        return "success";
    }
}
